<%@ page session="false"%><%@ page language="java" 	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%><%@ taglib	prefix="c" uri="http://java.sun.com/jsp/jstl/core"%><%@ taglib	prefix="x" uri="http://www.xunshibao.com/tags"%>
<div class="mt15">
<!--<p>
<a href="/message/viewmsg-id.html">上一封</a>
<a href="/message/viewmsg-id.html">下一封</a></p>
-->
<div style="float:right;clear:both;padding:10px;">
<c:choose>
<c:when test="${system }">
<a href="<%=request.getContextPath() %>/message/system">返回</a>
</c:when>
<c:otherwise><a href="<%=request.getContextPath() %>/message/inbox">返回</a></c:otherwise>
</c:choose>
<a href="javascript:void(0)" onClick="vdel(path + '/message/delete?mid=${m.msgId}')">删除</a>
</div>
<div id="reply"></div>
<c:choose>
<c:when test="${system }">
<c:forEach var="msg" items="${messages }" varStatus="idx"><div id="msg${idx.index}">
<div class="Charinfor clearfix mt10">
<p class="Oper">
</p>
<dl>
<dt>
<a href="javascript:void(0);">
<img id="avatar" src="<%=request.getContextPath() %>/avator/default_small.gif" class="touxiangall"  border="0"/>
</a>
</dt>
<dd class="ml10">
系统管理员
<p class="fc9"><x:intdate value="${msg.createdTime}" /></p></dd>
</dl>
</div>
<div class="SMScon fc6">
<p class="server"><strong>${msg. title}</strong></p>
<span class="content">${msg.content }</span>
</div>
</div></c:forEach>
</c:when>
<c:otherwise>
<c:forEach var="reply" items="${replies }" varStatus="idx"><div id="msg${idx.index}">
<div class="Charinfor clearfix mt10">
<p class="Oper">
</p>
<dl>
<dt>
<a href="http://shop.zhubajie.com/2555265" target="_blank">
<img id="avatar" src="<%=request.getContextPath() %>/avator/${reply.createUid }_small.jpg" class="touxiangall"  border="0" onerror="this.onerror=null;this.src='<%=request.getContextPath() %>/avator/default_small.gif'"/>
</a>
</dt>
<dd class="ml10">
<a href="http://shop.zhubajie.com/2555265">${reply.createUname }</a>
<p class="fc9"><x:intdate value="${reply.createtime }" /></p></dd>
</dl>
</div>
<div class="SMScon fc6">
<p class="server"><strong>${reply. title}</strong></p>
<span class="content">${reply.content }</span>
</div>
</div><c:set var="msgId" value="${reply.msgId}" /></c:forEach>
</c:otherwise>
</c:choose>

<c:if test="${empty system }">
<div class="Repmes">
<p><strong>回复信息：</strong></p>
<form id="frm_msg" name="frm_msg" method="POST" action="">
<input type="hidden" id="msgId" name="msgId" value="${msgId}" />
<input type="hidden" id="username" name="username" value="${username}" />
<textarea name="content" id="cont"></textarea>
</form>
<p class="mt5"><a class="at_but b_2_g" id="submit" href="javascript:void(0)"><u></u>提交回复</a></p>
</div>
</c:if>
</div>
<c:if test="${empty system }">
<script type="text/javascript">
Date.prototype.value = function(){
	return this.getFullYear() + '-' + this.getMonth() + 1 + '-' + this.getDate() + ' ' + this.getHours() + ':' + this.getMinutes() + ':' + this.getSeconds();
}
$.cookie("userid", 1);
function addReply(con){
	/*var t = $('#top');
	if(t.length == 0) {
		$('body').prepend($('<a name="top" id="top"></a>'));
	}*/
	var c = $('#msg0').clone();

	var tmp = c.find('dd');
	var uname = tmp.find('a');// 回复人名称
	uname.text($('#username').val());
	var utime = tmp.find('p');// 回复时间
	utime.text((new Date()).value());
	
	tmp = c.find('div.SMScon');
	var title = tmp.find('strong');// 标题
	title.text($('#username').val());
	var content = tmp.find('span');// 内容
	content.text(con);
	$('#reply').prepend(c);
	//$('#gogogo').trigger('click');
}

$('#submit').click(function(){
	//$(window).animate({top: '0px'}, 500);
	
	at_loading.show(); //等待对话框
	$.ajax({
		url:'<%=request.getContextPath()%>/message/reply',
		data:$('#frm_msg').serialize(),
		success:function(json) {
			at_loading.hide();
			addReply($('#cont').val());
			if(json.result) {
				var first = $('.pCenter');
				var firstTop = first.offset().top;
				//$(document).scrollTop(100);
				var bd = (window.opera)? (document.compatMode=="CSS1Compat"? $('html') : $('body')) : $('html,body');
				
				bd.animate({scrollTop: firstTop}, 500);
				$('#cont').val('');
				at_infoTrace.show("回复成功", "o");
			}
		}
	});
});
</script>
</c:if>